ServerEvents.tick(event => {
    const server = event.server
    const bossType = 'kubejs:avadon'
    const bossTag = 'avadon_title_shown' 
    
    const untaggedBase = `execute as @e[type=${bossType},nbt=!{BossFight:0b},tag=!${bossTag}] at @s if entity @a[distance=..32] run `
    
    server.runCommandSilent(
        `${untaggedBase}title @a[distance=..32] subtitle {"text":"§4§lSurpreme Flame","color":"#FFFFFF","italic":true}`
    )
    server.runCommandSilent(
        `${untaggedBase}title @a[distance=..32] title {"text":"§4§lAvadon","color":"#FFFFFF","bold":true}`
    )
    server.runCommandSilent(
        `execute as @e[type=${bossType},nbt=!{BossFight:0b},tag=!${bossTag}] run tag @s add ${bossTag}`
    )
    server.runCommandSilent(
        `execute as @e[type=${bossType},nbt={BossFight:0b},tag=${bossTag}] run tag @s remove ${bossTag}`
    )
});